import pandas as pd
from datetime import datetime,timedelta
# 打开文件
# path = r'E:\试飞数据\处理后ADS-B数据\20241014\ADSB2024-10-14(B001E).txt'
from pandas import DataFrame
# 设置读取和存储路径
# file = '20241022'
## 111架机ADS-B数据
WQAR_file_name1 = 'B-3328_20241021_052157_525463'
WQAR_file_name2 = 'B-3328_20241021_071045_525464'
WQAR_file_name3 = 'B-3328_20241021_084541_525465'

#读取路径
path1 = r'E:\试飞数据\WQAR数据\解析数据\AGS_Output' + '\\' + WQAR_file_name1 + '.csv'
path2 = r'E:\试飞数据\WQAR数据\解析数据\AGS_Output' + '\\' + WQAR_file_name2 + '.csv'
path3 = r'E:\试飞数据\WQAR数据\解析数据\AGS_Output' + '\\' + WQAR_file_name3 + '.csv'

read_list = ['UTC','PPLFR10','PPLFR11','HEAD_MAG_L','HEAD_MAG_R','RALTL','RALTR','CASL','CASR']
# 读取数据
df1 = pd.read_csv(path1,usecols= read_list)
df2 = pd.read_csv(path2,usecols= read_list)
df3 = pd.read_csv(path3,usecols= read_list)


# print(df1)
# print(df2)
# print(df3)
#
df_contact = pd.concat([df1, df2, df3], ignore_index=True)

#UTC时间转化为北京时间
df_bj_time = pd.to_datetime(df_contact['UTC']) + timedelta(hours=8)

df_contact['bj_time'] = df_bj_time

df_contact = df_contact.set_index('bj_time')

#对经纬度进行重新采样
df_rearrange1 = df_contact['PPLFR10','PPLFR11'].resample('1000ms', origin='start').interpolate(method='linear')

print(df_rearrange1)

# df_contact.index = df_contact.index.strftime("%H:%M:%S:%f")





# path_out = r'E:\试飞数据\WQAR数据\解析数据\AGS_Output' + '\\' +'WQAR_data_process' + '.txt'
#
# print(df_contact['PPLFR10'])

# df_contact.to_csv(path_out, sep = '\t')